1 : <?php
2 : /*--------------------------------------------------------------------------+
3 : This file is part of eStudy.
4 : news/classes/class.news.inc.php
5 : - Modulgruppe: News
6 : - Beschreibung: Klasse zur News-Seite.
7 : - Version: 1.22.22.8, 24/01/08
8 : - Autor(en): Mario Wagner <mario.wagner@mni.fh-giessen.de>
9 : Clemens Weiß <clemens.weiss@mni.fh-giessen.de>
10 : Corinna Kropf <corinna.kropf@mni.fh-giessen.de> (Refactoring)
11 : +---------------------------------------------------------------------------+
12 : This program is free software; you can redistribute it and/or
13 : modify it under the terms of the GNU General Public License
14 : as published by the Free Software Foundation; either version 2
15 : of the License, or any later version.
16 : +---------------------------------------------------------------------------+
17 : This program is distributed in the hope that it will be useful,
18 : but WITHOUT ANY WARRANTY; without even the implied warranty of
19 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 : GNU General Public License for more details.
21 : You should have received a copy of the GNU General Public License
22 : along with this program; if not, write to the Free Software
23 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 : +--------------------------------------------------------------------------*/
25 :
26 : /**
27 : * Implementierung der Klasse zur News-Seite.
28 : * @package eStudy.News
29 : * @version 1.22.22.8, 24/01/08
30 : * @author Mario Wagner <mario.wagner@mni.fh-giessen.de>
31 : * @author Clemens Weiß <clemens.weiss@mni.fh-giessen.de>
32 : * @author Corinna Kropf <corinna.kropf@mni.fh-giessen.de>
33 : */
34 :
35 : // Kategorien
36 1 : if (!defined("ANNOUNCEMENTS")) define("ANNOUNCEMENTS", 1);
37 1 : if (!defined("PM")) define("PM", 2);
38 1 : if (!defined("COURSES")) define("COURSES", 3);
39 1 : if (!defined("USER")) define("USER", 4);
40 1 : if (!defined("RESSOURCES")) define("RESSOURCES", 5);
41 1 : if (!defined("FORUMS")) define("FORUMS", 6);
42 1 : if (!defined("VOTINGS")) define("VOTINGS", 7);
43 1 : if (!defined("NOTD")) define("NOTD", 8);
44 1 : if (!defined("STYLES")) define("STYLES", 9);
45 1 : if (!defined("WAITINGLIST")) define("WAITINGLIST", 10);
46 1 : if (!defined("QUIZ")) define("QUIZ", 11);
47 1 : if (!defined("EXTERNALTOOLS")) define("EXTERNALTOOLS", 12);
48 1 : if (!defined("LITERATURE")) define("LITERATURE", 13);
49 1 : if (!defined("LERNGRUPPE")) define("LERNGRUPPE", 14);
50 1 : if (!defined("LERNGRUPPE_BLOG")) define("LERNGRUPPE_BLOG", 15);
51 1 : if (!defined("LERNGRUPPE_MEETING")) define("LERNGRUPPE_MEETING", 16);
52 1 : if (!defined("LERNGRUPPE_MEMBERS")) define("LERNGRUPPE_MEMBERS", 17);
53 1 : if (!defined("LERNGRUPPE_WAITINGLIST")) define("LERNGRUPPE_WAITINGLIST", 18);
54 :
55 1 : if (!defined("MEDIAWIKI")) define("MEDIAWIKI", 19);
56 1 : if (!defined("WORDPRESS")) define("WORDPRESS", 20);
57 :
58 1 : if (!defined("ECOM")) define("ECOM", 21);
59 :
60 1 : if (!defined("COURSEINVITE")) define("COURSEINVITE", 22);
61 :
62 :
63 : // Zeiträume
64 1 : if (!defined("LASTVISIT")) define("LASTVISIT", -1);
65 1 : if (!defined("COURSESTART")) define("COURSESTART", -2);
66 1 : if (!defined("REGDATE")) define("REGDATE", -3);
67 : // Kurs-News offen/geschlossen
68 1 : if (!defined("COURSEOPEN")) define("COURSEOPEN", 1);
69 1 : if (!defined("COURSECLOSED")) define("COURSECLOSED", 0);
70 1 : if (!defined("COURSETEMPCLOSED")) define("COURSETEMPCLOSED", -1);
71 1 : require_once ("class.style.inc.php");
72 1 : require_once ("class.roleartefacts.inc.php");
73 1 : require_once ("class.bbcode.inc.php");
74 :
75 1 : require_once ("class.newscategoryprivatemessages.inc.php");
76 1 : require_once ("class.newscategorywaitinglist.inc.php");
77 1 : require_once ("class.newscategorystyles.inc.php");
78 1 : require_once ("class.newscategoryexternaltools.inc.php");
79 1 : require_once ("class.newscategoryannouncements.inc.php");
80 1 : require_once ("class.newscategoryforum.inc.php");
81 1 : require_once ("class.newscategoryressources.inc.php");
82 1 : require_once ("class.newscategoryvotings.inc.php");
83 1 : require_once ("class.newscategoryquiz.inc.php");
84 1 : require_once ("class.newscategorymembers.inc.php");
85 1 : require_once ("class.newscategorycourse.inc.php");
86 1 : require_once ("class.newscategoryecom.inc.php");
87 1 : require_once ("class.newscategoryliterature.inc.php");
88 1 : require_once ("class.newscategorywordpress.inc.php");
89 1 : require_once ("class.newscategorycourseinvite.inc.php");
90 :
91 1 : require_once ("class.categorygateway.inc.php");
92 :
93 : /**
94 : * News bereitstellen.
95 : * Zusammenstellen und Ausgeben der News zu den Kursen
96 : *
97 : * @version 1.22.22.4, 07/01/08
98 : * @author Mario Wagner <mario.wagner@mni.fh-giessen.de>
99 : * @author Clemens Weiß <clemens.weiss@mni.fh-giessen.de>
100 : */
101 1 : class News {
102 : /**
103 : * Cache Objekt zur Abfrage von Modulinstallationen (Performance Tweak)
104 : * @var array
105 : */
106 : private $installCacheObject;
107 : /**
108 : * User-ID
109 : * @var int
110 : */
111 : private $userID;
112 : /**
113 : * Reihenfolge der anzuzeigenden Kategorien, siehe oben definierte
114 : * Konstanten
115 : * @var array
116 : */
117 : private $categories = array();
118 : /**
119 : * Kurse, in denen der User angemeldet ist
120 : * @var array
121 : */
122 : private $courses = array();
123 : /**
124 : * Timestamp des letzten Besuchs
125 : * @var int
126 : */
127 : private $lastvisit;
128 : /**
129 : * Einstellungen des Users zu allen News-Tabellen
130 : * @var array
131 : */
132 : private $preferences = array();
133 : /**
134 : * Einstellungen des Users zur aktuellen News-Tabelle
135 : * @var array
136 : */
137 : private $coursepref = array();
138 : /**
139 : * Standardeinstellungen für News-Tabelle, wenn noch nicht in DB gespeichert
140 : * @var array
141 : */
142 : private $stdCoursepref = array();
143 : /**
144 : * BBCode-Parser-Objekt zum Entfernen von BBCode-Tags
145 : * @var object
146 : */
147 : private $bbcode;
148 : /**
149 : * Lerngruppen, in denen der User angemeldet ist
150 : * @var array
151 : */
152 : private $newsCategories;
153 :
154 : /**
155 : * @var arrray
156 : */
157 : private $visibleCategories;
158 :
159 : /**
160 : * Zend_Translate - Objekt
161 : */
162 : private $translate;
163 :
164 : /**
165 : * Zend_Locale - Objekt
166 : */
167 : private $locale;
168 :
169 : /**
170 : * Konstruktor.
171 : * Auslesen der Userdaten, des letzten Besuchs, des Registrierdatums,
172 : * der Kurse und der Einstellungen
173 : *
174 : * @param $userID int User-ID
175 : * @param $lastvisit int Zu betrachtender Zeitraum als Unix-Timestamp. Wird
176 : * diese Angabe nicht gemacht, werden die Einstellungen des Benutzers
177 : * verwendet.
178 : */
179 : public function __construct($userID, $lastvisit = -1) {
180 0 : global $db;
181 :
182 0 : $this->locale = getLocale();
183 0 : $this->translate = getTranslate("news");
184 :
185 : // Cache Objekt zur Abfrage von modulinstallationen (vermeidet redundante DB Abfragen)
186 0 : $this->installCacheObject = Utilities::getInstallCacheObject();
187 :
188 0 : $this->userID = $userID;
189 :
190 0 : $userData = $this->userData();
191 :
192 0 : $this->courses = $this->courses($this->userData());
193 :
194 : // Foyer der Kursliste hinzufügen
195 0 : $foyer = array("ID" => "0", "Name" => "Foyer", "ShortName" => "Foyer", "OpenDate" => $userData->regdate, "Usergroup" => $userData->Usergroup);
196 0 : if (is_array($this->courses) && !empty($this->courses)) {
197 0 : array_unshift($this->courses, $foyer);
198 0 : } else {
199 0 : $this->courses = array(0 => $foyer);
200 : }
201 0 : $this->courses = Utilities::setArrayIndexes($this->courses, "ID");
202 :
203 : // Forencache Hack. Eingestellte Forenansichtszeiten für Kurse müssen alle gleich sein.
204 0 : $cat6 = $db->get_var("SELECT category6 FROM news_preferences WHERE userID='$this->userID' LIMIT 1");
205 0 : if ($cat6 != null)
206 0 : $cat6Pref = array('category6' => $cat6);
207 : else
208 0 : $cat6Pref = array('category6' => LASTVISIT);
209 :
210 : // Standard-Kurs-Einstellungen, falls noch nicht festgelegt (d.h. kein Eintrag in der DB)
211 0 : $this->stdCoursepref = array("courseID" => 0, "courseOpen" => COURSECLOSED, "category1" => LASTVISIT, "category2" => LASTVISIT, "category3" => LASTVISIT, "category4" => LASTVISIT, "category5" => LASTVISIT, $cat6Pref, "category7" => LASTVISIT, "category11" => LASTVISIT, "category13" => LASTVISIT, "category20" => LASTVISIT );
212 : // Wurde ein Timestamp übergeben, diesen als Zeitraum verwenden,
213 : // ansonsten die Einstellungen des Benutzers laden
214 0 : if ($lastvisit > -1) {
215 0 : $this->lastvisit = $lastvisit;
216 0 : $this->coursepref = $this->stdCoursepref;
217 0 : } else {
218 0 : if ($userData->lastlogout < $userData->lastlogin2) {
219 0 : $this->lastvisit = $userData->lastlogin2;
220 0 : } else {
221 0 : $this->lastvisit = $userData->lastlogout;
222 : }
223 0 : $this->preferences = $this->getPreferences();
224 : // if ($this->preferences == null)
225 : // $this->preferences = $this->stdCoursepref;
226 : }
227 0 : $this->categories = array(NOTD, WAITINGLIST, EXTERNALTOOLS, STYLES, ANNOUNCEMENTS, FORUMS, RESSOURCES, VOTINGS, QUIZ, USER, COURSES, ECOM, LITERATURE, WORDPRESS /*, MEDIAWIKI*/);
228 : // MEDIAWIKI, WORDPRESS
229 :
230 0 : $categoryGateway = new CategoryGateway($db, new Data(), $userID);
231 0 : $this->visibleCategories = $categoryGateway->loadVisible();
232 :
233 : // Ein Objekt fuer jede Kategorieklasse erstellen
234 0 : $this->newsCategories();
235 :
236 0 : $this->bbcode = new BBCode();
237 0 : }
238 :
239 : private function courses($userData) {
240 0 : global $db;
241 :
242 0 : if ($this->userData()->Usergroup != ADMIN) {
243 : $sql = "SELECT ID, Name, ShortName, OpenDate, IF(differentUsergroup>0, differentUsergroup, "
244 0 : . $userData->Usergroup
245 0 : . ") AS Usergroup, Type FROM user_course JOIN courses ON courseID=ID WHERE userID='$this->userID' AND closed='0' ORDER BY ShortName";
246 0 : } else {
247 : // Admin sieht alle Kurse, die nicht geschlossen sind
248 : $sql = "SELECT ID, Name, ShortName, OpenDate, 1 AS Usergroup, Type "
249 : . "FROM courses "
250 0 : . "WHERE closed = 0 ORDER BY ShortName";
251 : }
252 :
253 0 : return $db->get_results($sql, ARRAY_A);
254 : }
255 :
256 : private function userData() {
257 0 : global $db;
258 0 : return $db->get_row("SELECT Usergroup, regdate, lastlogin2, lastlogout FROM user WHERE ID='$this->userID'");
259 : }
260 :
261 : private function newsCategories() {
262 0 : if ($this->newsCategories === null) {
263 :
264 0 : $this->newsCategories = array();
265 :
266 0 : $this->newsCategories[PM] = new NewsCategoryPrivateMessages(PM, $this->courses, $this->userID, new Category(PM, 0, '', true));
267 0 : if ($this->visibleCategories->hasCategory(WAITINGLIST)) {
268 0 : $category = $this->visibleCategories->getCategory(WAITINGLIST);
269 0 : $this->newsCategories[WAITINGLIST] = new NewsCategoryWaitinglist(WAITINGLIST, $this->courses, $category);
270 0 : }
271 0 : if ($this->visibleCategories->hasCategory(STYLES)) {
272 0 : $category = $this->visibleCategories->getCategory(STYLES);
273 0 : $this->newsCategories[STYLES] = new NewsCategoryStyles(STYLES, $this->courses, $category);
274 0 : }
275 0 : if ($this->visibleCategories->hasCategory(EXTERNALTOOLS)) {
276 0 : $category = $this->visibleCategories->getCategory(EXTERNALTOOLS);
277 0 : $this->newsCategories[EXTERNALTOOLS] = new NewsCategoryExternalTools(EXTERNALTOOLS, $this->courses, $category, $this->installCacheObject);
278 0 : }
279 0 : if ($this->visibleCategories->hasCategory(ANNOUNCEMENTS)) {
280 0 : $category = $this->visibleCategories->getCategory(ANNOUNCEMENTS);
281 0 : $this->newsCategories[ANNOUNCEMENTS] = new NewsCategoryAnnouncements(ANNOUNCEMENTS, $this->courses, $category, $this->installCacheObject);
282 0 : }
283 0 : if ($this->visibleCategories->hasCategory(FORUMS)) {
284 0 : $category = $this->visibleCategories->getCategory(FORUMS);
285 0 : $this->newsCategories[FORUMS] = new NewsCategoryForum(FORUMS, $this->courses, $this->userID, $category, $this->installCacheObject);
286 0 : }
287 0 : if ($this->visibleCategories->hasCategory(RESSOURCES)) {
288 0 : $category = $this->visibleCategories->getCategory(RESSOURCES);
289 0 : $this->newsCategories[RESSOURCES] = new NewsCategoryRessources(RESSOURCES, $this->courses, $this->userID, $category, $this->installCacheObject);
290 0 : }
291 0 : if ($this->visibleCategories->hasCategory(VOTINGS)) {
292 0 : $category = $this->visibleCategories->getCategory(VOTINGS);
293 0 : $this->newsCategories[VOTINGS] = new NewsCategoryVotings(VOTINGS, $this->courses, $category, $this->installCacheObject);
294 0 : }
295 0 : if ($this->visibleCategories->hasCategory(QUIZ)) {
296 0 : $category = $this->visibleCategories->getCategory(QUIZ);
297 0 : $this->newsCategories[QUIZ] = new NewsCategoryQuiz(QUIZ, $this->courses, $category, $this->installCacheObject);
298 0 : }
299 0 : if ($this->visibleCategories->hasCategory(USER)) {
300 0 : $category = $this->visibleCategories->getCategory(USER);
301 0 : $this->newsCategories[USER] = new NewsCategoryMembers(USER, $this->courses, $category);
302 0 : }
303 0 : if ($this->visibleCategories->hasCategory(COURSES)) {
304 0 : $category = $this->visibleCategories->getCategory(COURSES);
305 0 : $this->newsCategories[COURSES] = new NewsCategoryCourse(COURSES, $this->courses, $this->userID, $category);
306 0 : }
307 0 : if ($this->visibleCategories->hasCategory(ECOM)) {
308 0 : $category = $this->visibleCategories->getCategory(ECOM);
309 0 : $this->newsCategories[ECOM] = new NewsCategoryEcom(ECOM, $this->courses, $this->userID, $category);
310 0 : }
311 0 : if ($this->visibleCategories->hasCategory(LITERATURE)) {
312 0 : $category = $this->visibleCategories->getCategory(LITERATURE);
313 0 : $this->newsCategories[LITERATURE] = new NewsCategoryLiterature(LITERATURE, $this->courses, $category, $this->installCacheObject);
314 0 : }
315 0 : if ($this->visibleCategories->hasCategory(WORDPRESS)) {
316 0 : $category = $this->visibleCategories->getCategory(WORDPRESS);
317 0 : $this->newsCategories[WORDPRESS] = new NewsCategoryWordPress(WORDPRESS, $this->courses, $this->userID, $category, $this->installCacheObject);
318 0 : }
319 0 : if ($this->visibleCategories->hasCategory(COURSEINVITE)) {
320 0 : $category = $this->visibleCategories->getCategory(COURSEINVITE);
321 0 : $this->newsCategories[COURSEINVITE] = new NewsCategoryCourseInvite(COURSEINVITE, $this->courses, $this->userID, $category, $this->installCacheObject);
322 0 : }
323 0 : }
324 :
325 0 : return $this->newsCategories;
326 : }
327 :
328 : public static function getCategoryNames() {
329 : return array(
330 1 : STYLES => "Styles",
331 1 : WAITINGLIST => "Warteliste",
332 1 : EXTERNALTOOLS => "Externe Tools",
333 1 : ANNOUNCEMENTS => "Mitteilungen",
334 1 : FORUMS => "Forenbeiträge",
335 1 : RESSOURCES => "Ressourcen",
336 1 : VOTINGS => "Umfragen",
337 1 : QUIZ => "Lernquiz",
338 1 : USER => "Mitglieder",
339 1 : COURSES => "Kurse",
340 1 : LITERATURE => "Literaturempfehlungen",
341 1 : WORDPRESS => "Wordpress-Blogeinträge",
342 1 : ECOM => "eCommunities",
343 1 : COURSEINVITE => "Einladungen"
344 1 : );
345 : }
346 :
347 : public static function getCategoryName($id) {
348 0 : $names = self::getCategoryNames();
349 0 : return isset($names[$id]) ? $names[$id] : "";
350 : }
351 :
352 : /**
353 : * Gibt den Timestamp des letzten Besuchs oder den im Konstruktor
354 : * angegebenen Zeitraum zurück.
355 : *
356 : * @return int Timestamp
357 : */
358 : public function getLastVisit() {
359 0 : return (int)$this->lastvisit;
360 : }
361 : /**
362 : * Erzeugt die Willkommensnachricht im Foyer
363 : *
364 : * @param $userGroup array Array mit Gruppenzugehörigkeit und Helpid
365 : * @param $ldapUserInfo string Falls vorhanden LDAP Informationen
366 : * @return string
367 : */
368 : public function echoWelcomeNote($userGroup, $ldapUserInfo = '') {
369 0 : $salutation = $this->getSalutation();
370 0 : $title = $this->getTitle();
371 0 : $username = Data::toHTML(ucfirst($_SESSION["Vorname"]) ." ".ucfirst($_SESSION["Nachname"]), false);
372 0 : $usergroup = Data::toHTML($userGroup['role'], false);
373 0 : $userGroupInfo = Utilities::getHelp($userGroup['helpid']);
374 :
375 0 : $date = new Zend_Date($this->getLastVisit(), $this->locale);
376 0 : $lastVisitDate = $date->get(Zend_Date::DATE_FULL);
377 0 : $lastVisitTime = $date->get(Zend_Date::TIME_SHORT);
378 0 : $welcomeMsg = $this->translate->_("willkommen im Foyer des eStudy-Portals!");
379 :
380 0 : $welcomeNote = new Template(PATH_TO_ROOT."news/templates/welcomenote.html");
381 :
382 0 : $userInfo = sprintf($this->translate->_( "Sie gehören der eStudy-Benutzergruppe " %1\$s " %2\$s an."), $usergroup, $userGroupInfo );
383 0 : $lastVisitMsg = sprintf($this->translate->_("Ihr letzter Besuch war am %1\$s um %2\$s Uhr"), $lastVisitDate, $lastVisitTime);
384 0 : eval($welcomeNote->GetTemplate());
385 0 : }
386 :
387 : /**
388 : * Erzeugt die Willkommensnachricht im Foyer
389 : *
390 : * @param $status int Status 0 = deaktiviert, 1 = aktiviert
391 : * @param $cssClass bool CSS Klasse um das Layout anzupassen
392 : * @return string
393 : */
394 : public function echoWelcomeNoteImage($status) {
395 0 : if ($status) {
396 0 : $title = $this->translate->_('Willkommensbotschaft abschalten');
397 0 : $param = 'f';
398 0 : $cssClass = 'newsWelcomeLeftOn';
399 0 : $imageCssClass = 'icon_arrowbottom';
400 0 : } else {
401 0 : $title = $this->translate->_('Willkommensbotschaft anzeigen');
402 0 : $param = 't';
403 0 : $cssClass = 'newsWelcomeLeftOff';
404 0 : $imageCssClass = 'icon_arrowtop';
405 : }
406 0 : $welcomeNoteImage = new Template(PATH_TO_ROOT."news/templates/welcomenoteimage.html");
407 0 : eval($welcomeNoteImage->GetTemplate());
408 0 : }
409 : /**
410 : * Speichern des Status der Willkommesbotschaft im Foyer
411 : *
412 : * @param $status int Status 0 = deaktiviert, 1 = aktiviert
413 : * @return boolean
414 : */
415 : public function setWelcomeNoteStatus($status) {
416 0 : global $db;
417 0 : $c_status = 1;
418 0 : if ($status == 'f') $c_status = 0;
419 0 : $db->query("UPDATE user SET welcome_note='$c_status' WHERE ID='".$_SESSION['userid']."'");
420 0 : $_SESSION['welcomeNote'] = $c_status;
421 0 : }
422 : /**
423 : * Gibt den Status Status der Willkommesbotschaft zurück
424 : *
425 : * @return string
426 : */
427 : public function getWelcomeNoteStatus() {
428 0 : return ($_SESSION['welcomeNote'] == 1 ? true : false);
429 : }
430 :
431 : /**
432 : * Gibt die Anrede zurück (Frau/Herr)
433 : *
434 : * @return bool mixed
435 : */
436 : public function getSalutation() {
437 0 : if(!isset($_SESSION['gender']))
438 0 : return false;
439 :
440 0 : $salutation = '';
441 :
442 : // 0 = nicht definiert, 1 = Männlich, 2 = Weiblich
443 0 : switch($_SESSION['gender']) {
444 0 : case 1:
445 0 : $salutation = 'Herr';
446 0 : break;
447 0 : case 2:
448 0 : $salutation = 'Frau';
449 0 : break;
450 0 : }
451 :
452 0 : return $salutation;
453 : }
454 :
455 : /**
456 : * Gibt den Akademischen Grad/Titel zurück zurück (Dr./Prof./Prof. Dr.)
457 : *
458 : * @return bool mixed
459 : */
460 : public function getTitle() {
461 0 : if(!isset($_SESSION['salutation'])) return false;
462 :
463 0 : $title = '';
464 :
465 : // 0 = nicht definiert, 1 = Herr, 2 = Frau, 3 = Dr., 4 = Prof., 5 = Prof. Dr., 6 = Prof. Dr. Dr.
466 0 : if(isset($_SESSION['salutation'])) {
467 0 : switch($_SESSION['salutation']) {
468 0 : case 3:
469 0 : $title = 'Dr.';
470 0 : break;
471 0 : case 4:
472 0 : $title = 'Prof.';
473 0 : break;
474 0 : case 5:
475 0 : $title = 'Prof. Dr.';
476 0 : break;
477 0 : case 6:
478 0 : $title = 'Prof. Dr. Dr.';
479 0 : break;
480 0 : }
481 0 : }
482 :
483 0 : return $title;
484 : }
485 :
486 : /**
487 : * Speichern des Anzeigezeitraums der einzelnen News-Kategorien (z.B.
488 : * Mitteilungen, PNs, Forenbeitraege etc.)
489 : *
490 : * @access public
491 : * @param $courseID int Kurs-ID, für die Einstellungen gespeichert werden
492 : * @param $category int Kategorie-Nr: 1=Mitteilungen, 2=Private Nachrichten,
493 : * 3=Kurse, 4=Mitglieder, 5=Ressourcen, 6=Forenbeiträge, 7=Umfragen
494 : * @param $period int Anzeigezeitraum in Tagen oder: -1=Seit letztem Besuch,
495 : * -2=Seit Kursbeginn, -3=Seit Portalanmeldung
496 : */
497 : public function setCategoryPreferences($courseID, $category, $period) {
498 0 : global $db;
499 :
500 0 : if ($courseID != strval(intval($courseID)) || $category != strval(intval($category)) || (!in_array($category, $this->categories) && $category != PM) || $period != strval(intval($period)) || $period < -3 || $period == 0) return;
501 : /*$update = false;
502 : if (!empty($this->preferences)) foreach($this->preferences as $preference) if ($preference["courseID"] == $courseID) {
503 : $update = true;
504 : break;
505 : }*/
506 : // Performance Tweak. Der Cache für Forennews funktioniert nur wenn für alle Kurse der gleiche Anzeigezeitraum fürs Forum eingestellt ist
507 : // Beim Ändern eines Anzeigezeitraums werden daher auch alle anderen Anzeigeeinstellungen für Forennews in anderen Kursen gleich gesetzt
508 0 : $update = false;
509 0 : $res = $db->get_col("SELECT courseID FROM news_preferences WHERE userID='$this->userID' AND courseID='$courseID'");
510 0 : if ($res != null)
511 0 : $update = true;
512 0 : if ($update) {
513 0 : $sql = "UPDATE news_preferences SET category$category='$period' WHERE userID='$this->userID' ";
514 0 : if ($category != FORUMS)
515 0 : $sql .= "AND courseID='$courseID'";
516 0 : $db->query($sql);
517 0 : }
518 : else {
519 0 : $sql = "INSERT INTO news_preferences (userID, courseID, category$category) VALUES ('$this->userID', '$courseID', '$period')";
520 0 : $db->query($sql);
521 : // Für Forum auch alle anderen Kurse auf selbe Forenanzeige setzen
522 0 : if ($category == FORUMS)
523 0 : $db->query("UPDATE news_preferences SET category$category='$period' WHERE userID='$this->userID' ");
524 : }
525 0 : $this->preferences = $this->getPreferences();
526 0 : }
527 : /**
528 : * Speichern des Anzeigestatus der einzelnen Kurs-News (Offen/Geschlossen)
529 : *
530 : * @param $courseID int Kurs-ID, für die Einstellungen gespeichert werden
531 : * @param $courseOpen int 0=Kurs geschlossen, -1=Kurs geschlossen und auch
532 : * trotz News geschlossen anzeigen, 1=Kurs geöffnet
533 : */
534 : public function setCoursePreferences($courseID, $courseOpen) {
535 0 : global $db;
536 :
537 0 : if ($courseID != strval(intval($courseID)) || $courseOpen != strval(intval($courseOpen)) || $courseOpen < -1 || $courseOpen > 1)
538 0 : return;
539 :
540 0 : if ($courseOpen == -1) {
541 0 : $_SESSION["tempClosedCourseNews"][$courseID] = $courseID;
542 0 : $courseOpen = 0;
543 0 : }
544 :
545 0 : if ($courseOpen == 1 && isset($_SESSION["tempClosedCourseNews"][$courseID]))
546 0 : unset($_SESSION["tempClosedCourseNews"][$courseID]);
547 :
548 0 : $update = false;
549 :
550 0 : if (!empty($this->preferences)) foreach($this->preferences as $preference) if ($preference["courseID"] == $courseID) {
551 0 : $update = true;
552 0 : break;
553 : }
554 0 : if ($update)
555 0 : $db->query("UPDATE news_preferences SET courseOpen='".Data::toMysql($courseOpen)."' WHERE userID='".Data::toMysql($this->userID)."' AND courseID='".Data::toMysql($courseID)."'");
556 : else
557 0 : $db->query("INSERT INTO news_preferences (userID, courseID, courseOpen) VALUES ('".Data::toMysql($this->userID)."', '".Data::toMysql($courseID)."', '".Data::toMysql($courseOpen)."')");
558 :
559 0 : $this->preferences = $this->getPreferences();
560 0 : }
561 :
562 : /**
563 : * Listet die verpassten Kurse auf.
564 : *
565 : */
566 : public function listMissedCourses() {
567 0 : foreach($this->courses as $course) {
568 : // Im Foyer alle Kurse ausgeben, sonst nur den aktuell gewählten
569 0 : if ($_SESSION["course"] == 0 || $_SESSION["course"] == $course["ID"]) {
570 : // Hat der aktuell behandelte Kurs schon Einstellungen in der DB,
571 : // dann Standardeinstellungen überschreiben
572 0 : $this->coursepref = $this->stdCoursepref;
573 :
574 0 : if (isset($this->preferences[$course["ID"]]))
575 0 : $this->coursepref = $this->preferences[$course["ID"]];
576 :
577 : // News sammeln
578 0 : $news = $this->getNews($course["ID"], true);
579 :
580 : // Nur Kursüberschrift ausgeben, wenn News vorhanden
581 0 : if ($news['count'] > 0) {
582 : // Kurs-Name für Überschrift "Neues aus dem Kurs..."
583 0 : if ( $course["ID"] > 0 && $course['Type'] == 'ecom' ) {
584 0 : $courseName = sprintf($this->translate->_("der eCommunity: »<i>%1\$s</i>«"), $course["Name"]);
585 0 : $courseString = $this->translate->_('zur eCommunity');
586 0 : } else {
587 0 : $courseName = ($course["ID"] > 0 ? sprintf($this->translate->_("dem Kurs: »%1\$s«"),$course["Name"]) : $this->translate->_("dem Foyer"));
588 0 : $courseString = $this->translate->_('zum Kurs');
589 : }
590 :
591 : // zeige verlinkten Kurz-Namen eines Kurses nur im Foyer
592 0 : $linkedShortName = "";
593 0 : if (!$_SESSION["course"] && $course["ID"])
594 0 : $linkedShortName = " (<a href='".PATH_TO_ROOT."veranst.php?Course=$course[ID]' "."title='Direkt $courseString $course[ShortName]'>$course[ShortName]</a>)";
595 :
596 :
597 : // Einstellungen für den Übergabeparameter courseOpen
598 0 : if ($this->coursepref["courseOpen"] == COURSEOPEN) {
599 0 : $courseOpenParam = COURSECLOSED;
600 0 : if ($news["count"] > 0) $courseOpenParam = COURSETEMPCLOSED;
601 0 : } else { // Kurs-News geschlossen
602 0 : $courseOpenParam = COURSEOPEN;
603 0 : if ($news["count"] > 0 && !isset($_SESSION["tempClosedCourseNews"][$course["ID"]])) {
604 0 : $courseOpenParam = COURSETEMPCLOSED;
605 0 : $this->coursepref["courseOpen"] = COURSEOPEN; // Kurs geöffnet anzeigen, wenn News vorhanden
606 0 : }
607 : }
608 : // Kopf-Tabelle ausgeben
609 0 : $altText = ($course["ID"] ? $this->translate->_("Kurs") : $this->translate->_("Foyer")).
610 0 : "-News ".
611 0 : ($this->coursepref["courseOpen"] == COURSEOPEN ? $this->translate->_("schließen") : $this->translate->_("öffnen"));
612 0 : $newsFrom = $this->translate->_("Neues aus");
613 0 : $toTopIcon = Output::getIcon("icon_totop", $this->translate->_("Zum Seitenanfang"));
614 0 : $courseOpenCloseIcon = Output::getIcon("icon_".($this->coursepref["courseOpen"] ? "minimize" : "maximize"), $altText);
615 0 : $showAll = isset($_GET['showAll']) ? "showAll=42&" : "";
616 0 : $g_ZumSeitenanfang = $this->translate->_("Zum Seitenanfang");
617 :
618 0 : $courseHeader = new Template(PATH_TO_ROOT."news/templates/newsheader_course.html");
619 0 : eval($courseHeader->GetTemplate());
620 : // Wenn Kurs laut Einstellungen offen ist, News anzeigen
621 0 : if ($this->coursepref["courseOpen"] == COURSEOPEN) {
622 0 : echo "<tr><td colspan='2' class='newsCourseBlockContent'>";
623 0 : $this->echoNews($news, $course["ID"]);
624 0 : echo "</td></tr>\n";
625 0 : }
626 0 : echo "</table>\n";
627 0 : }
628 0 : }
629 0 : }
630 0 : }
631 :
632 : /**
633 : * Geht die Kurse inkl. Foyer durch, gibt den Kursueberschriftsbalken aus
634 : * und ruft getNews() und echoNews() fuer jeden Kurs auf
635 : * Die HTML-Struktur kann/sollte noch angepasst werden
636 : */
637 : public function listCourses() {
638 0 : $this->echoSpecialNewsControls();
639 0 : echo "<div id='newsCourseList'>\n";
640 0 : foreach($this->courses as $course) {
641 : // Im Foyer alle Kurse ausgeben, sonst nur den aktuell gewählten
642 0 : if ($_SESSION["course"] == 0 || $_SESSION["course"] == $course["ID"]) {
643 : // Hat der aktuell behandelte Kurs schon Einstellungen in der DB,
644 : // dann Standardeinstellungen ¸berschreiben
645 0 : $this->coursepref = $this->stdCoursepref;
646 :
647 0 : if (isset($this->preferences[$course["ID"]])) {
648 0 : $this->coursepref = $this->preferences[$course["ID"]];
649 0 : }
650 :
651 : // Kurs-Name für Überschrift "Neues aus dem Kurs..."
652 0 : if ( $course["ID"] > 0 && $course['Type'] == 'ecom' ) {
653 0 : $courseName = sprintf($this->translate->_("der eCommunity: »<i>%1\$s</i>«"), $course["Name"]);
654 0 : $courseString = $this->translate->_('zur eCommunity');
655 0 : } else {
656 0 : $courseName = ($course["ID"] > 0 ? sprintf($this->translate->_("dem Kurs: »%1\$s«"),$course["Name"]) : $this->translate->_("dem Foyer"));
657 0 : $courseString = $this->translate->_('zum Kurs');
658 : }
659 :
660 : // zeige verlinkten Kurz-Namen eines Kurses nur im Foyer
661 0 : $linkedShortName = "";
662 0 : if (!$_SESSION["course"] && $course["ID"])
663 0 : $linkedShortName = " (<a href='".PATH_TO_ROOT."veranst.php?Course=$course[ID]' "."title='Direkt $courseString $course[ShortName]'>$course[ShortName]</a>)";
664 :
665 : // News sammeln
666 0 : $news = $this->getNews($course["ID"]);
667 0 : if ( ! $this->hasNews($course["ID"])) {
668 0 : continue;
669 : }
670 : // Einstellungen fuer den Uebergabeparameter courseOpen
671 0 : if ($this->coursepref["courseOpen"] == COURSEOPEN) {
672 0 : $courseOpenParam = COURSECLOSED;
673 0 : if ($news["count"] > 0) $courseOpenParam = COURSETEMPCLOSED;
674 0 : } else { // Kurs-News geschlossen
675 0 : $courseOpenParam = COURSEOPEN;
676 0 : if ($news["count"] > 0 && !isset($_SESSION["tempClosedCourseNews"][$course["ID"]])) {
677 0 : $courseOpenParam = COURSETEMPCLOSED;
678 0 : $this->coursepref["courseOpen"] = COURSEOPEN; // Kurs geöffnet anzeigen, wenn News vorhanden
679 0 : }
680 : }
681 : // Kopf-Tabelle ausgeben
682 0 : $altText = ($course["ID"] ? $this->translate->_("Kurs") : $this->translate->_("Foyer")).
683 0 : "-News ".
684 0 : ($this->coursepref["courseOpen"] == COURSEOPEN ? $this->translate->_("schließen") : $this->translate->_("öffnen"));
685 0 : $newsFrom = $this->translate->_("Neues aus");
686 0 : $toTopIcon = Output::getIcon("icon_totop", $this->translate->_("Zum Seitenanfang"));
687 0 : $courseOpenCloseIcon = Output::getIcon("icon_".($this->coursepref["courseOpen"] ? "minimize" : "maximize"), $altText);
688 :
689 0 : $g_ZumSeitenanfang = $this->translate->_("Zum Seitenanfang");
690 :
691 0 : $showAll = isset($_GET['showAll']) ? "showAll=42&" : "";
692 0 : $courseHeader = new Template(PATH_TO_ROOT."news/templates/newsheader_course.html");
693 0 : eval($courseHeader->GetTemplate());
694 : // Wenn Kurs laut Einstellungen offen ist, News anzeigen
695 0 : if ($this->coursepref["courseOpen"] == COURSEOPEN) {
696 0 : echo "<tr><td colspan='2' class='newsCourseBlockContent'>";
697 0 : $this->echoNews($news, $course["ID"]);
698 0 : echo "</td></tr>\n";
699 0 : }
700 0 : echo "</table>\n";
701 0 : }
702 0 : }
703 0 : echo "</div>\n";
704 0 : }
705 :
706 : public function loadCoursePreferences() {
707 0 : foreach($this->courses as $course) {
708 : // Hat der aktuell behandelte Kurs schon Einstellungen in der DB,
709 : // dann Standardeinstellungen ¸berschreiben
710 0 : $this->coursepref = $this->stdCoursepref;
711 : // Forencache Tweak. Alle Kurse müssen den gleichen Forenzeitraum haben
712 0 : global $db;
713 0 : $cat6Pref = $db->get_var("SELECT category6 FROM news_preferences WHERE userID='$this->userID' LIMIT 1");
714 0 : if (isset($this->preferences[$course["ID"]])) {
715 0 : $this->coursepref = $this->preferences[$course["ID"]];
716 0 : }
717 0 : if ($cat6Pref != null)
718 0 : $this->coursepref["category6"] = $cat6Pref;
719 :
720 0 : }
721 0 : }
722 :
723 : private function echoSpecialNewsControls() {
724 0 : $showAllSwitchText = isset($_GET['showAll']) ? "Ausgewählte Ereignisse" : "Alle Ereignisse";
725 0 : $showAllSwitch = isset($_GET['showAll']) ? "" : "?showAll=";
726 0 : $showAllIcon = isset($_GET['showAll']) ? "icon_minimize" : "icon_maximize";
727 0 : include PATH_TO_ROOT . "news/templates/specialcontrols.phtml";
728 0 : }
729 :
730 : private function hasNews($courseID) {
731 0 : if (isset($_GET['showAll'])) return true;
732 :
733 0 : foreach($this->newsCategories as $categories) {
734 0 : if ($categories->hasNews($courseID)) {
735 0 : return true;
736 : }
737 0 : }
738 0 : return false;
739 : }
740 :
741 : /**
742 : * Gibt die Privaten Nachrichten aus
743 : *
744 : * @param $courseID int ID des aktuell behandelten Kurses
745 : */
746 : public function echoPrivateMessages($courseID) {
747 0 : if ($this->newsCategories[PM]->isInstalled($courseID)) {
748 0 : $this->coursepref = $this->stdCoursepref;
749 0 : if (isset($this->preferences[0])) $this->coursepref = $this->preferences[0];
750 :
751 0 : if ( isset($this->courses[$courseID]) ) {
752 0 : $usergroup = $this->courses[$courseID]["Usergroup"];
753 0 : } else {
754 0 : $usergroup = "";
755 : }
756 :
757 0 : $this->newsCategories[PM]->setCoursePreferences($this->coursepref["category2"]);
758 0 : $catNews = $this->newsCategories[PM]->getNews($courseID, $this->lastvisit, $usergroup);
759 0 : $this->newsCategories[PM]->echoNewsTableHead(0);
760 0 : if(!empty($catNews))
761 0 : {
762 0 : if($catNews["count"]>0)
763 0 : {
764 0 : echo "<table cellspacing='0'>";
765 0 : $this->newsCategories[PM]->echoNews($courseID);
766 0 : echo "</table>";
767 0 : }
768 0 : }
769 0 : if ($this->newsCategories[PM]->hasNews($courseID)) echo "</td></tr></table>";
770 : // PNs wurden angezeigt, jetzt nicht mehr verwenden. Sonst werden neue PNs
771 : // auch als News von allen Kursen gezaehlt.
772 0 : unset($this->newsCategories[PM]);
773 0 : }
774 0 : }
775 :
776 : public function getSumOfAllNews() {
777 0 : $newscount = 0;
778 0 : foreach ($this->courses as $course) {
779 0 : $news = $this->getNews($course['ID']);
780 0 : $newscount += $news['count'];
781 0 : }
782 0 : return $newscount;
783 : }
784 :
785 : /**
786 : * Stellt die News der einzelnen Kategorien des behandelten Kurses zusammen
787 : *
788 : * @param $courseID int ID des aktuell behandelten Kurses
789 : * @param boolean $missed Wird angegeben, falls verpasste Neuigkeiten gesammelt werden sollen.
790 : * @return $news array Array mit allen News des behandelten Kurses
791 : */
792 : public function getNews($courseID, $missed = false) {
793 0 : global $db;
794 0 : $usergroup = $this->courses[$courseID]["Usergroup"];
795 0 : $news = array("count" => 0, "user" => array());
796 : // News of the Day
797 0 : $news[NOTD] = $db->get_var("SELECT message FROM news_of_the_day WHERE courseID='$courseID' AND time>='".$this->lastvisit."'");
798 0 : if ($db->num_rows == 0 || empty($news[NOTD])) unset($news[NOTD]);
799 0 : elseif ($courseID > 0 && isset($_SESSION["course"]) && $_SESSION["course"] != $courseID) $news["count"]++; // Zähler nur erhöhen, wenn NotD auf der News-Seite angezeigt werden soll
800 :
801 0 : foreach($this->newsCategories as $category) {
802 : // Private Nachrichten gehoeren nicht zu den Kursen und fliegen daher raus.
803 0 : if ( $category instanceof NewsCategoryPrivateMessages ) continue;
804 0 : $catID = $category->getCategory();
805 :
806 0 : if ($catID == WORDPRESS) continue;
807 :
808 0 : if ($category->isInstalled($courseID, $category)) {
809 0 : if(isset($this->coursepref["category$catID"])) {
810 0 : $category->setCoursePreferences($this->coursepref["category$catID"]);
811 0 : }
812 :
813 0 : if ($missed) {
814 0 : $catNews = $category->getMissedNews($courseID, $this->lastvisit, $usergroup);
815 0 : } else {
816 0 : $catNews = $category->getNews($courseID, $this->lastvisit, $usergroup);
817 : }
818 :
819 0 : if(!empty($catID)) {
820 0 : $news[$catID] = $catNews;
821 0 : $news["count"] += $catNews["count"];
822 0 : if ( is_array($category->getUsers()) ) {
823 0 : $news["user"] += $category->getUsers();
824 0 : }
825 0 : }
826 0 : }
827 0 : }
828 : // Benutzerdaten laden
829 0 : if (isset($news["user"]) && count($news["user"]) > 0) {
830 0 : $user = array_map("intval", array_values($news["user"]));
831 0 : $user = $db->get_results("SELECT ID, Vorname, Nachname, Usergroup, gender FROM user WHERE ID IN (".implode(",", $user) .")", ARRAY_A);
832 0 : $news["user"] = Utilities::setArrayIndexes($user, "ID");
833 0 : }
834 :
835 0 : return $news;
836 : }
837 :
838 : /**
839 : * Gibt die Klartextbezeichnung und die Hilfeseiten-ID der Benutzergruppe zurück
840 : *
841 : * @param $val int
842 : * @return array
843 : */
844 : public function getUserGroupDescription($val) {
845 0 : $desc = array();
846 0 : if ($val == '') return false;
847 :
848 : switch ($val) {
849 0 : case ADMIN:
850 0 : $desc['role'] = 'Admin';
851 0 : $desc['helpid'] = 600;
852 0 : break;
853 0 : case STUDENT:
854 0 : $desc['role'] = 'Student';
855 0 : $desc['helpid'] = 601;
856 0 : break;
857 0 : case DOZENT:
858 0 : $desc['role'] = 'Dozent';
859 0 : $desc['helpid'] = 602;
860 0 : break;
861 0 : case SEKRETARIAT:
862 0 : $desc['role'] = 'Sekretariat';
863 0 : $desc['helpid'] = 603;
864 0 : break;
865 0 : case ALUMNUS:
866 0 : $desc['role'] = 'Alumnus';
867 0 : $desc['helpid'] = 606;
868 0 : break;
869 0 : case SCHUELER:
870 0 : $desc['role'] = 'Schüler';
871 0 : $desc['helpid'] = 607;
872 0 : break;
873 0 : case GAST:
874 0 : $desc['role'] = 'Gast';
875 0 : $desc['helpid'] = 608;
876 0 : break;
877 0 : default:
878 0 : $desc['role'] = 'Student';
879 0 : $desc['helpid'] = 601;
880 0 : break;
881 0 : }
882 :
883 : /*
884 : * Admin (root) und Anonym erhalten eine Sonderbehandlung.
885 : * Da sich aber Anonym und root nicht in der UserGroup unterscheiden,
886 : * hier nochmal die Überprüfung anhand der userid
887 : * (können mehrere Admins definiert sein)
888 : */
889 0 : if($_SESSION['userid'] == 1) {
890 0 : $desc['role'] = 'root';
891 0 : $desc['helpid'] = 605;
892 0 : }
893 0 : else if($_SESSION['userid'] == 2) {
894 0 : $desc['role'] = 'Gasthörer(in)';
895 0 : $desc['helpid'] = 604;
896 0 : }
897 :
898 0 : return $desc;
899 : }
900 : /**
901 : * Ausgabe der News des aktuell behandelten Kurses unterhalb des Kursüberschriftsbalkens
902 : *
903 : * @param $news array Array mit den Kurs-News
904 : * @param $courseID int ID des aktuell behandelten Kurses
905 : */
906 : public function echoNews($news, $courseID) {
907 0 : $usergroup = $this->courses[$courseID]["Usergroup"];
908 0 : $showOnlyIfRelevant_List = array(NOTD, WAITINGLIST, STYLES, EXTERNALTOOLS /*, MEDIAWIKI*/);
909 : // , MEDIAWIKI, WORDPRESS
910 : // , LERNGRUPPE
911 :
912 0 : $newsCategoryOrder = array();
913 0 : foreach ($this->visibleCategories as $position => $category) {
914 0 : $newsCategoryOrder[$position] = $category->getId();
915 0 : }
916 :
917 0 : foreach($newsCategoryOrder as $category) {
918 0 : if(in_array($category, $showOnlyIfRelevant_List) && !isset($news[$category])) continue;
919 :
920 0 : $showNewsTableHead = false;
921 :
922 0 : if(isset($this->newsCategories[$category])) {
923 0 : $showNewsTableHead = $this->newsCategories[$category]->isInstalled($courseID);
924 : if ($showNewsTableHead)
925 0 : $this->newsCategories[$category]->echoNewsTableHead($courseID, (isset($this->courses[$courseID]['Type']) ? $this->courses[$courseID]['Type'] : null ));
926 0 : }
927 :
928 0 : if (isset($news[$category])) {
929 0 : echo "<table cellspacing='0'>";
930 : // News of the Day
931 0 : if ($category == NOTD) {
932 0 : if($courseID > 0 && $_SESSION["course"] != $courseID) {
933 0 : $notdText = Utilities::chopText($news[NOTD]);
934 0 : $notdLink = "(<a href='news.php?changeToCourse=".Data::toHTML($courseID)."' title='Zur Kurs-Newsseite'>" . $this->translate->_("Lesen") . "</a>)";
935 0 : $notdTemplate = new Template(PATH_TO_ROOT."news/templates/newsnotd.html");
936 0 : eval($notdTemplate->GetTemplate());
937 0 : }
938 0 : } else {
939 0 : $this->newsCategories[$category]->echoNews($courseID, $usergroup);
940 : }
941 0 : echo "</table>";
942 0 : }
943 0 : if ($showNewsTableHead && $this->newsCategories[$category]->hasNews($courseID)) echo "</td></tr></table>\n";
944 0 : }
945 0 : }
946 :
947 : /**
948 : * Gibt zurück, ob es potenziell verpasste Neuigkeiten gibt, oder nicht.
949 : *
950 : * @return boolean <code>true</code, falls es verpasste Neuigkeiten in irgend einem Kurs gibt, <code>false</code, falls nicht.
951 : */
952 : public function hasMissedNews() {
953 :
954 : /* News von allen Kursen überprüfen */
955 0 : foreach($this->courses as $course) {
956 :
957 0 : $this->coursepref = $this->stdCoursepref;
958 :
959 0 : if (isset($this->preferences[$course["ID"]]))
960 0 : $this->coursepref = $this->preferences[$course["ID"]];
961 :
962 0 : $news = $this->getNews($course["ID"], true);
963 :
964 : /* Potenziell verpasste News vorhanden */
965 0 : if ($news['count'] != 0) {
966 0 : return true;
967 : }
968 0 : }
969 :
970 0 : return false;
971 : }
972 :
973 : // ----------------------------------- Hilfsfunktionen -----------------------------------
974 :
975 : /**
976 : * Liest die Anzeige-Einstellungen des Benutzers aus der Datenbank
977 : *
978 : * @return array Einstellungen
979 : */
980 : protected function getPreferences() {
981 0 : global $db;
982 0 : $prefs = $db->get_results("SELECT * FROM news_preferences WHERE userID='$this->userID' ORDER BY courseID", ARRAY_A);
983 0 : return Utilities::setArrayIndexes($prefs, "courseID");
984 : }
985 : }
|